#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define rept(i,n) for(int i=0;i<n;i++)
#define ll long long

struct node{
    int l,r;
}a[100005];

ll t,p[100005],sum[10000005];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    cin>>t;
    while(t--){
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        rep(i,n){
            int td,tv,ta;
            cin>>td>>tv>>ta;
            long double tx=0.5;
            if(ta==0){
                if(tv>v){
                    a[i].l=td;
                    a[i].r=l;
                }
                else{
                    a[i].l=-1;
                    a[i].r=-1;
                }
            }
            else if(ta>0){
                if(tv>v){
                    a[i].l=td;
                    a[i].r=l;
                }
                else{
                    a[i].l=td+ceil((v*v-tv*tv)*tx/ta);
                    a[i].r=l;
                }
            }
            else{
                if(tv>v){
                    a[i].l=td;
                    a[i].r=td+(v*v-tv*tv)*tx/ta;
                }
                else{
                    a[i].l=-1;
                    a[i].r=-1;
                }
            }
        }
        rep(i,1500000)sum[i]=0;
        rep(i,m){
            cin>>p[i];
            sum[p[i]]=1;
        }

        rep(i,1500000){
            sum[i]+=sum[i-1];
        }
        int ans=0;
        rep(i,n){
            if(a[i].l!=-1){
                if(sum[min(a[i].r,l)]-sum[max(a[i].l-1,0)]>0){
                    ans++;
                }
            }
        }
        cout<<ans<<' ';

        int c[1000005]={0},cnt[1000005]={0};
        rep(i,n){
            c[a[i].l]++;
            c[a[i].r+1]--;
        }
        int maxn=-1,maxi,num=n;
        rep(i,1000000){
            cnt[i]=cnt[i-1]+c[i];
        }
        ans=0;
        while(num>0){
            maxn=-1;
            rep(i,1000000){
                if(maxn<cnt[i]){
                    maxn=cnt[i];
                    maxi=i;
                }
            }
            rep(i,n){
                if(a[i].l<=maxi&&a[i].r>=maxi){
                    c[a[i].l]--;
                    c[a[i].r+1]++;
                    num--;
                }
            }
            rep(i,1000000){
                cnt[i]=cnt[i-1]+c[i];
            }
            ans++;
        }
        cout<<ans<<endl;
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}
